e4f6b40b7460871ac1e408677361e6a29c94ee29,openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/SalFlowServiceImpl.java,SalFlowServiceImpl,updateFlow,#UpdateFlowInput#,94

Before Change


        }

        allFlowMods.addAll(ofFlowModInputs);
        ListenableFuture<RpcResult<UpdateFlowOutput>> future = flowUpdate.processFlowModInputBuilders(allFlowMods);
        Futures.addCallback(future, new UpdateFlowCallback(input));
        return future;
    }

After Change


        final List<FlowModInputBuilder> ofFlowModInputs;

        ListenableFuture<RpcResult<UpdateFlowOutput>> future;
        if (flowUpdateMessage.isSupported()) {

            if (!FlowCreatorUtil.canModifyFlow(original, updated, flowUpdateMessage.getVersion())) {
                final SettableFuture<RpcResult<UpdateFlowOutput>> objectSettableFuture = SettableFuture.create();

                final ListenableFuture<List<RpcResult<UpdateFlowOutput>>> listListenableFuture = Futures.successfulAsList(
                        flowUpdateMessage.handleServiceCall(input.getOriginalFlow()),
                        flowUpdateMessage.handleServiceCall(input.getUpdatedFlow()));

                Futures.addCallback(listListenableFuture, new FutureCallback<List<RpcResult<UpdateFlowOutput>>>() {
                    @Override
                    public void onSuccess(final List<RpcResult<UpdateFlowOutput>> results) {
                        final ArrayList<RpcError> errors = new ArrayList();
                        for (RpcResult<UpdateFlowOutput> flowModResult : results) {
                            if (flowModResult == null) {
                                errors.add(RpcResultBuilder.newError(
                                        RpcError.ErrorType.PROTOCOL, OFConstants.APPLICATION_TAG,
                                        "unexpected flowMod result (null) occurred"));
                            } else if (!flowModResult.isSuccessful()) {
                                errors.addAll(flowModResult.getErrors());
                            }
                        }

                        final RpcResultBuilder<UpdateFlowOutput> rpcResultBuilder;
                        if (errors.isEmpty()) {
                            rpcResultBuilder = RpcResultBuilder.success();
                        } else {
                            rpcResultBuilder = RpcResultBuilder.<UpdateFlowOutput>failed().withRpcErrors(errors);
                        }

                        objectSettableFuture.set(rpcResultBuilder.build());
                    }

                    @Override
                    public void onFailure(final Throwable t) {
                        RpcResultBuilder<UpdateFlowOutput> rpcResultBuilder = RpcResultBuilder.failed();
                        objectSettableFuture.set(rpcResultBuilder.build());
                    }
                });

                future = objectSettableFuture;
            } else {
                future = flowUpdateMessage.handleServiceCall(input.getUpdatedFlow());
            }
        } else {
            if (!FlowCreatorUtil.canModifyFlow(original, updated, flowUpdate.getVersion())) {
                // We would need to remove original and add updated.

                // remove flow
                final RemoveFlowInputBuilder removeflow = new RemoveFlowInputBuilder(original);
                final List<FlowModInputBuilder> ofFlowRemoveInput = flowUpdate.toFlowModInputs(removeflow.build());
                // remove flow should be the first
                allFlowMods.addAll(ofFlowRemoveInput);
                final AddFlowInputBuilder addFlowInputBuilder = new AddFlowInputBuilder(updated);
                ofFlowModInputs = flowUpdate.toFlowModInputs(addFlowInputBuilder.build());
            } else {
                ofFlowModInputs = flowUpdate.toFlowModInputs(updated);
            }

            allFlowMods.addAll(ofFlowModInputs);

            future = flowUpdate.processFlowModInputBuilders(allFlowMods);
        }

        Futures.addCallback(future, new UpdateFlowCallback(input));